// #include "test.h"
#include "Subject.h"
#include "Observer.h"

int main() {
    // 秘书
    Subject* secretary = new Secretary();

    // 同事
    Observer* tongshi1 = new StockObserver("张三", secretary);
    Observer* tongshi2 = new NBAObserver("李四", secretary);

    // 同事订阅的Subject
    secretary->Attach(tongshi1);
    secretary->Attach(tongshi2);

    // 老板回来了
    secretary->SubjectState = "warnning !!! : 老板回来了";
    // 向订阅者发出通知
    secretary->Notify();

    // NBA同事接触订阅
    std::cout << "NBA的同事取消了订阅" << std::endl;
    secretary->Detach(tongshi2);

    // 老板回来了
    secretary->SubjectState = "warnning !!! : 老板再次回来了";
    // 向订阅者发出通知
    secretary->Notify();

    return 0;
}

/*
看股票的同事收到消息：warnning !!! : 老板回来了
看NBA的同事收到消息：warnning !!! : 老板回来了
NBA的同事取消了订阅
看股票的同事收到消息：warnning !!! : 老板再次回来了
*/